- 5 minutes to read

JSON formatted Log Event

This article provides examples with detailed information on a technical level intended to guide developers to create JSON formatted Log Events for use within your custom logging solutions. The JSON formatted Log Events may be sent directly to the LogAPI or sent to a queue/folder for asynchronous fetch by the Pickup Service (recommended approach).

The Log Event has three distinct parts:

  1. Event details (also named Additional field values within Nodinite)
    • You can use the field function in the Formula plugin to extract the values
  2. Payload (Body, 0 or more)
    • You can use the body function in the Formula plugin to extract the values from virtually any payload
  3. Context properties (Key/Value)
    • You can use the context function in the Formula plugin to extract the values from the key/value collection
graph TD subgraph "Log Event" subgraph "1. Details" roED[fal:fa-bolt Event Details
LogDateTime = 2018-05-03 13:37:00+02:00
EndPointName = https://api.nodinite.com/...
MessageType=Invoice
...] end subgraph "2. Payload" ro[fal:fa-envelope Message
Body=base64EncodedMessage] end subgraph "3. Context Properties" roKey[fal:fa-key Key Values
InvoiceNo = 123
CorrelationId=456
...] end end

1. Details

The first 7 event fields are mandatory and the rest of the fields are optional (set value to null or do not provide the field at all). By providing additional details about the Log Event; Nodinite end-users may have a better user experience.

Mandatory Data Type Field Value Comment
number LogAgentValueId 42 Who (Log Agents) sent the data
string EndPointName "INT101: Receive Hello World Log Events" Name of Endpoint transport
string EndPointUri "C:\DropArea\in" URI for Endpoint transport
number EndPointDirection 0 Direction for Endpoint transport
number EndPointTypeId 60 Type of Endpoint transport
string OriginalMessageTypeName "https://nodinite.com/Customers/1.0#Batch" Message Type Name
string LogDateTime "2018-05-03T13:37:00.123Z" Client Log datetime (UTC format)
number EventDirection 17 External Incoming (before receive port)
string ProcessingUser "DOMAIN\user" Log Identity
number SequenceNo 0 Provide your own sequence number
number EventNumber 0 Provide your own event number
string LogText "File successfully generated" Your log text goes here
string ApplicationInterchangeId "" Id for Application scope
guid LocalInterchangeId null Id for local scope
string LogStatus 0 As defined for each Log Agent
string ProcessName "My customer process" Name of process
string ProcessingMachineName "localhost" Name of server where log event originated
string ProcessingModuleName "INT101-HelloHappyCustomers-Application" Name of module
string ProcessingModuleType "FilePickup" Type of module, exe, dll, service
guid ServiceInstanceActivityId null Id for run scope
number ProcessingTime 80 Flow execution time so far in milliseconds

LogDateTime - Provide timezone data for example -01:00, +02:00 or Z. If time zone data is not provided then UTC-time will be used. Value from LogDateTime is always converted to UTC time and stored as that in Nodinite databases. This means that Nodinite will present the correct date time for end-users regardless of which timezone you happen to view logged events.

Example: 2017-04-10T08:44:22.309+02:00 (+02:00 against UTC)

Value for the guid data type is sent without brackets or null.

Example: "064205E2-F7CF-43A6-B514-4B55536C2B67"

2. Payload

The payload is optional, and can either be a single message payload (normal and the default) or you can provide multiple payloads (for example attachments in email)

Body

The payload/body - is a base64 encoded string / file or null. You can omit the "Body" field totally if you have no "Body" to log.

Mandatory Data Type Field Value Comment
string Body "SGVsbG8gV29ybGQ=" base64 encoded string

Bodies

If you have multiple payloads, then you should use the Bodies element instead of the Body element.

Mandatory Data Type Field Value Comment
Array string Bodies ["SGVsbG8=", "V29ybGQ="] base64 encoded strings

3. Context Properties

The Context properties are simply a collection of key/values. Feel free to send whatever you need to create usable self-service Log Views for your business.

You can omit the "Context" field totally if you have no context properties to log.

...
"Context": {
    "CorrelationId": "064205E2-F7CF-43A6-B514-4B55536C2B67",
    "FileName": "\\server\\share\\NodiniteHappyCustomerList.txt"
}
Mandatory Data Type Field Value Comment
array Context { "Key1": "ABC", "Key2": "123"} comma separated list of key values of string data type

Repository

By providing additional details in the Context, the Repository Model may be populated with that information when processed by the Logging Service. Read more about this topic in the documentation for Context Options.

Full Example

Complete Log Event with all available fields set, optional and mandatory:

{
  "LogAgentValueId": 42,
  "EndPointName": "INT101: Receive Hello World Log Events",
  "EndPointUri": "C:\\temp\\in",
  "EndPointDirection": 0,
  "EndPointTypeId": 60,
  "OriginalMessageTypeName": "Hello.World.File/1.0",
  "LogDateTime": "2017-11-22T08:44:22.309Z",
  "EventDirection": "17",
  "ProcessingUser": "DOMAIN\\user",
  "SequenceNo": 0,
  "EventNumber": 0,
  "LogText": "File OK",
  "ApplicationInterchangeId": "",
  "LocalInterchangeId": null,
  "LogStatus": 0,
  "ProcessName": "My Process",
  "ProcessingMachineName": "localhost",
  "ProcessingModuleName": "INT101-HelloWorld-Application",
  "ProcessingModuleType": "FilePickup",
  "ServiceInstanceActivityId": null,
  "ProcessingTime": 80,
  "Body": "SGVsbG8gV29ybGQ=",
  "Context": {
      "CorrelationId": "064205E2-F7CF-43A6-B514-4B55536C2B67",
      "FileName": "Hello.txt"
  }
}

Minimal Example

Minimal incoming Log Event with mandatory fields (endpoint is file based in this example):

{
  "LogAgentValueId": 42,
  "EndPointName": "INT101: Receive Hello World Log Events",
  "EndPointUri": "C:\\temp\\in",
  "EndPointDirection": 0,
  "EndPointTypeId": 60,
  "OriginalMessageTypeName": "Hello.World.File/1.0",
  "LogDateTime": "2017-11-22T08:44:22.309Z"  
}

Next Step